<?php
	require_once("conexion/conexion.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>--</title>
<link href="Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="include_js/jquery.js" type="text/javascript"></script>

<style>
.texto
{
	font-size:14px;
	margin-left:10px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.asterisco
{
	color:#0000FF;
	font-weight:bold;
}
.radioBorde
{ 
 background:#D3E4E5;
 border:0px solid #89C0C7;
}
.filaPar
{
	background:#81D371; 
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.filaImpar
{
	background:#AEF1A1;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
</style>
<script>
function validar(e)
{ 
    tecla = (document.all) ? e.keyCode : e.which; 
    if (tecla==8) return true; //Tecla de retroceso (para poder borrar) 
    patron = /\d/;
    te = String.fromCharCode(tecla); 
    return patron.test(te);  
} 

function CargaDescuento(valor)
{
	//alert(valor);
	if(valor!='VACACIONES')
	{
		document.getElementById('dcto').style.display = 'block';
		document.form_PagoSueldo.descuento.checked= true;
		document.getElementById('txtDescto').value = 'SI';
	}
	else
	{
		document.getElementById('dcto').style.display = 'none';
		document.getElementById('txtDescto').value = 'NO';
	}
}
function ActivaDescto()
{
	if(document.form_PagoSueldo.descuento.checked)
	{
		document.getElementById('txtDescto').value = 'SI';
	}
	else
	{
		document.getElementById('txtDescto').value = 'NO';
	}
}

function BorraDatos(dato)
{
	var cadena = dato.substring(8,9);
    if(cadena=='1')
	{
		document.getElementById("cmb_Empleado").value= 0;
		document.getElementById('cmb_Motivo').value = 0;
		document.getElementById('txtDias').value = "";
		document.getElementById("cmb_Mes").value = 0;
		document.getElementById("cmb_Agno").value = 2010;
		document.getElementById("txtObs").value = "";
		document.getElementById('txtDescto').value= "";
		document.getElementById('dcto').style.display= "none";
	}
}
</script>

</head>

<body>
<form name="form_PagoSueldo" id="form_PagoSueldo" method="post">
<div class='option2'><label style="font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;">Inasistencia del Empleado.</label></div>
<div class='groupbox'>
<table width="100%" border="0" cellpadding="0" class="uno">
<tr>
  <td class="borde" colspan="2"><div style="float:left; clear:none; margin-left:10px; margin-top:5px;"><label style="color:#0000FF; font-size:12px; font-weight:bold;">Datos Obligatorios(*)</label></div></td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr><td class="borde" colspan="4"><hr /></td></tr>
<tr>
  	<td width="4%" class="borde">&nbsp;</td>
	<td width="3%" class="borde">&nbsp;</td>
	<td width="11%" class="borde">&nbsp;</td>
	<td width="38%" class="borde">&nbsp;</td>
    </tr>
  <tr>
    <td class="borde"><label class="texto" style="margin-left:35px;">Empleado:</label></td>
	<td class="borde" colspan="3"><select name="cmb_Empleado" id="cmb_Empleado" >
		<option value="0">--EMPLEADO--</option>
		<?php
			$con = new Conexion();
    		$con2 = $con->conexionBD("fpproduccion");
			$sql = "select EmpRut,EmpNombre,EmpApPaterno,EmpApMaterno from empleado";
			$resultado = mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
			while ($row = mysql_fetch_row($resultado))
			{
				echo "<option value='".$row[0]."'>".utf8_decode($row[1])." ".utf8_decode($row[2])." ".utf8_decode($row[3])."</option>";
			}
            $con->cerrarBD();
		?>
	  </select>&nbsp;<label class="asterisco">*</label></td>
    </tr>
  <tr>
    <td class="borde"><label class="texto" style="margin-left:35px;">Motivo:</label></td>
    <td class="borde" colspan="2"><select name="cmb_Motivo" id="cmb_Motivo" onchange="CargaDescuento(this.value);">
	<option value="0">--MOTIVO--</option>
	<option value="FALLA">FALLA</option>
	<option value="LICENCIA">LICENCIA</option>
	<option value="PERMISO">PERMISO</option>
	<option value="VACACIONES">VACACIONES</option>
    </select>&nbsp;<label class="asterisco">*</label></td>
    <td class="borde"><div id="dcto" style="display:none"><input name="descuento" type="checkbox" value="" onclick="ActivaDescto();" /><label class="texto">Descuento al Sueldo.</label></div></td>
    </tr>
  <tr>
    <td class="borde"><label class="texto" style="margin-left:35px;">N&deg; Dias:</label></td>
    <td class="borde"><input type="text" name="txtDias" size="4" onkeypress="return validar(event)" maxlength="2" />&nbsp;<label class="asterisco">*</label></td>
    <td class="borde" colspan="2"><label class="texto" style="margin-left:35px;">Mes:</label>
	<select name="cmb_Mes">
        <option value="0">--MES--</option>
        <option value="01">ENERO</option>
        <option value="02">FEBRERO</option>
        <option value="03">MARZO</option>
        <option value="04">ABRIL</option>
        <option value="05">MAYO</option>
        <option value="06">JUNIO</option>
        <option value="07">JULIO</option>
        <option value="08">AGOSTO</option>
        <option value="09">SEPTIEMBRE</option>
        <option value="10">OCTUBRE</option>
        <option value="11">NOVIEMBRE</option>
        <option value="12">DICIEMBRE</option>
      </select>&nbsp;<label class="asterisco">*</label>
	  <label class="texto">A&ntilde;o:</label>
	<select name="cmb_Agno">
        <option value="2010">2010</option>
        <option value="2011">2011</option>
        <option value="2012">2012</option>
      </select></td>
    </tr>
  <tr>
    <td class="borde"><label class="texto" style="margin-left:35px;">Observaci&oacute;n:</label></td>
    <td class="borde" colspan="3"><textarea name="txtObs" rows="3" cols="65"></textarea>
      <input type="hidden" name="txtDescto" id="txtDescto" /></td>
    </tr>
  <tr>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    <td class="borde">&nbsp;</td>
    </tr>
  
  <tr>
    <td class="borde" colspan="4"><div class="formtail"><input name="btn_Guardar" id="btn_Guardar" type="button" value=" " class="guardar" /></div></td>
  </tr>
</table>
</div>
</form>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><div id="mensaje"></div></td>
  </tr>
</table>
</body>
<script>
$('#btn_Guardar').click(function() 
{ 
        $.ajax({
            type: 'POST',
            url: 'Remuneracion/Ingresa_Inasistencia.php',
            data: $('#form_PagoSueldo').serialize(),
            success: function(data) {
                $('#mensaje').html(data);
				BorraDatos(data);
            }
        })
});
</script>
</html>